/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.santi.framework.util;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 *
 * @author Prabhat
 */
public class TokenReader {

    public static String[] readTokens(String strInput, String strDelimiter) {
        String strEMPTY = "";
        String[] arrReturn = {strEMPTY};
        if (null != strInput && null != strDelimiter) {
            arrReturn =
                    (new String(strInput.replaceAll(strDelimiter + strDelimiter,
                    strDelimiter + strEMPTY
                    + strDelimiter))).split(strDelimiter,
                    -1);
        } // end if
        return arrReturn;
    } // end readTokens

    public static List<String> readTokens(String strInput) {
        ArrayList<String> tokenList = null;
        if (!StringUtil.isNullOrBlank(strInput)) {
            tokenList = new ArrayList<String>();
            StringTokenizer stk = new StringTokenizer(strInput);
            while (stk.hasMoreTokens()) {
                String token = stk.nextToken();
                tokenList.add(token);

            }
        }

        return tokenList;
    } // end readTokens
}
